<@t.plat_body pageid="notices">
<style>
    .table>thead>tr>th, .table>tbody>tr>th, .table>tfoot>tr>th, .table>thead>tr>td, .table>tbody>tr>td, .table>tfoot>tr>td{
        padding: 4px;
    }
    input:read-only{
        background-color:#f1f1f1;
    }

    input{
        border: 1px solid #c1c1c1;
    }
    select:disabled{
        background-color: #f1f1f1;
    }
</style>
<script type="text/javascript" src="${base}/js/plugins/buttons/spin.min.js"></script>
<script type="text/javascript" src="${base}/js/plugins/buttons/ladda.min.js"></script>
<script type='text/javascript' src='${base}/js/plugins/laydate/laydate.js'></script>

<#--<link rel="stylesheet" href="${base}/ueditor/css/global.css">-->
<#--<link rel="stylesheet" href="${base}/ueditor/font/iconfont.css">-->

<div class="panel panel-flat">
    <div class="panel-heading">
        <h5 class="panel-title">添加公告</h5>
    </div>
    <div class="panel-body">
        <form id="commentForm">
            <input name="id" id="id" type="hidden" value="${command.id}"/>
            <table class="table table-striped table-bordered" style="width: 1000px">
                <tr>
                    <th width="120">公告标题*：</th>
                    <td>
                        <input  type="text" id="title" value="${command.title}" name="title" style="width: 320px" class="form-control"/>
                    </td>
                </tr>
                <tr>
                    <th width="120">启用状态：</th>
                    <td>
                        <select id="flag" name="flag" class="form-control" style="width: 320px">
                            <option value="1" ${(command.flag=='1')?string('selected="selected"','')}>启用</option>
                            <option value="0" ${(command.flag=='0')?string('selected="selected"','')}>禁用</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <th width="120">启用起止时间	：</th>
                    <td>
                        <#if command?exists>
                            <input type="text" id="start_end" value="${command.startdate?date} - ${command.enddate?date}" name="start_end" size="30" class="form-control" style="width: 320px"/>
                            <input type="hidden" id="startdate" value="${command.startdate?date}" name="startdate" size="30" />
                            <input  type="hidden" id="enddate" value="${command.enddate?date}" name="enddate" size="30" />
                        <#else>
                            <input type="text" id="start_end" name="start_end" size="30" class="form-control" style="width: 320px"/>
                            <input type="hidden" id="startdate"  name="startdate" size="30" />
                            <input  type="hidden" id="enddate"  name="enddate" size="30" />
                        </#if>

                    </td>
                </tr>

                <tr>
                    <th width="120">公告内容	：</th>
                    <td >
                        <div style="width: 800px">
                            <textarea id="container" name="content"  edit="" required></textarea>
                            <script type="text/plain" id="upload_ue" style="display:none"></script>
                        </div>

                    </td>
                </tr>
            </table>
        </form>
        <div style="text-align: center;margin-top: 10px">
            <button style="width: 120px" class="btn btn-primary btn-ladda btn-ladda-spinner" data-style="expand-right" data-spinner-color="#333" data-spinner-size="20" type="button" onclick="save()">提交</button>
        </div>
    </div>
</div>
<script type="text/javascript" charset="utf-8" src="${base}/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="${base}/ueditor/ueditor.all.min.js"> </script>
<script>
    var editor;
    $(function () {
        editor = UE.getEditor('container', {initialFrameHeight: 400});
        editor.addListener('ready', function() {
            editor.setContent('${command.content}', true);
        });
    })
    laydate.render({
        elem: '#start_end'
        ,type: 'date'
        ,format: 'yyyy-MM-dd'
        ,range: true
        ,done: function(value, date, endDate){
            var vals = value.split(' - ');
            if(vals.length==2){
                $('#startdate').val(vals[0])
                $('#enddate').val(vals[1])
            }else{
                $('#startdate').val('');
                $('#enddate').val('');
            }
        }
    });


    function save() {
        var name;
        var startdate=$('#startdate').val();
        var enddate=$('#enddate').val();

        var flag=$('#flag').val();
        var id=$('#id').val();
        var title=$('#title').val();
        if((name=checkNull($("#title")))===false) {
            return;
        }
        startdate=startdate?new Date(Date.parse(startdate.replace(/-/g,"/"))):null;
        enddate=enddate?new Date(Date.parse(enddate+' 23:59:39'.replace(/-/g,"/"))):null;


        var l = Ladda.create( document.querySelector( '.btn-ladda-spinner' ) );
        l.start();
        post('pl/nt/save',{content:editor.getContent(),name:name,startdate:startdate,id:id,enddate:enddate,flag:flag,title:title},function (result) {
            if(result.code==0){
                window.location.href='${base}/plat/notice/notices'
            }else{
                alertError(result.message);
            }
            l.stop();
        });

    }
</script>

</@t.plat_body>
